package link;

public class Constants {
	
	/**
	 * maximum size of the PAYLOAD in bytes (this is without error correction in place)
	 */
	public static final int MAX_PAYLOAD_SIZE = 50;
	
	/**
	 * The maximum size of a Frame, this is with length-header and error correction in place
	 */
	public static final int MAX_FRAME_SIZE = (MAX_PAYLOAD_SIZE) * 2;
	
	/**
	 * The time in milliseconds the sender has to wait before sending a new packet
	 */
	public static final long SEND_WAIT_TIME = 20;

	/**
	 * The multiplier for the random() extra wait (effectivly adding maximal SEND_WAIT_TIME_RAND ms to
	 * the SEND_WAIT_TIME)
	 */
	public static final long SEND_WAIT_TIME_RAND = 80;
	
	/**
	 * the time (in ms) we sleep when we suspect a lpt-pak could be a STOP sequence
	 */
	public static final long COULD_BE_STOP_SLEEP_TIME = 10;
	
	/**
	 * the time (in ms) after which the tranmission of a frame times out and we default to WAITING
	 * After this timeout we need to wait some time (AFTER_TIMEOUT_WAIT) so the other side also times out
	 * and then we start the random send/rec-timer
	 */
	public static final long SEND_REC_TIMEOUT = 200;
	
	/**
	 * The time (in ms) we wait after a SEND_REC_TIMEOUT t make sure the other side also had his SEND_REC_TIMEOUT
	 */
	public static final long AFTER_TIMEOUT_WAIT = 100;
	
	/**
	 * The number of times a value has to be read, before it is considered the current value on
	 * the LPT cable
	 * @invariant READ_TRESHOLD <= MAX_READ_TRYS
	 */
	public static final int READ_TRESHOLD = 3;
	
	/**
	 * The maximum number of times a read is tried before the current most
	 * read value is returned
	 * @invariant MAX_READ_TRYS >= READ_TRESHOLD
	 */
	public static final int MAX_READ_TRYS = 5;

}
